linux下关闭【防火墙 & seLinux】

禁用seLinux

查看状态

script
1
[root@localhost ~]#  sestatus

暂时关闭

暂时关闭,重启失效

script
1
[root@localhost ~]#  setenforce 0

永久关闭

设置SELINUX=disabled,需要重启。

1
2
3
4
5
6
7
8
9
10
11
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

关闭防火墙

CentOS 7

查看状态

script
1
[root@localhost ~]# firewall-cmd --state

或者

script
1
[root@localhost ~]# systemctl status firewalld

暂时关闭
script
1
[root@localhost ~]# systemctl stop firewalld.service
永久关闭
script
1
2
# 禁止firewall开机启动
[root@localhost ~]# systemctl disable firewalld.service

CentOS 6

查看状态
script
1
[root@localhost ~]# service iptables status
暂时关闭
1
[root@localhost ~]# service iptables stop
永久关闭
1
[root@localhost ~]# chkconfig iptables off